﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.LogicEntity;

namespace ueEngine.Biz.Core.AppService.Member
{
    public class SeekerService
    {
        private string userName = string.Empty;
        public SeekerService(string username)
        {
            this.userName = username;
        }
        
        /// <summary>
        /// 注册一个求职者
        /// </summary>
        /// <param name="password"></param>
        /// <param name="confirm"></param>
        /// <returns></returns>
        public SeekerService Register(string password, string confirm,string location="",int collage=-1)
        {
            var item = new UserService(userName).Register(password, confirm, false,"",location,(Collage)collage);
            if (item != null)
            {
                return this;
            }
            return null;
        }
        /// <summary>
        /// 新添加关注
        /// </summary>
        /// <param name="target"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public AttentionModel NewAttentionTarget(string target, AttentionType type)
        {
            var item = new AttentionModel().Element(c => c.Master == userName && c.Target == target && c.AttentionType == (int)type);
            //如果不存在重复项
            if (item == null)
            {
                return new AttentionModel() { 
                    AddDate = DateTime.Now,
                    AttentionType = type,
                    Master = userName,
                    Target = target
                }.PostAdd();
            }
            return item;
        }

    }
}
